import request from '@/utils/request'
import type { BaseResponse } from '@/types/index'

// 登录参数类型
interface LoginParams {
  mobile: string
  password: string
}

// 用户信息类型
interface UserInfo {
  id: number
  mobile: string
  avatar: string
  roles: string[]
}

//登录
export function login(store_id: string, data: LoginParams) {
  return request.get<BaseResponse>({
    url: `/memberAuth/memberLogin`,
    params: data,
    headers: { store_id },
  })
}
//驾校信息
export function getStoreInfo() {
  return request.get<BaseResponse>({
    url: `pcMember/info`,
  })
}
//题库
export function questionBank(data: object) {
  return request.post<BaseResponse>({
    url: `pcExam/getQuestionAll`,
    data,
  })
}
//保存题库
export function getQuestionProgress(data: object) {
  return request.post<BaseResponse>({
    url: `/pcExam/updateProgress`,
    data,
  })
}
// 用户详情重置密码
export function resetPassword(memberId: number, data: string) {
  return request.put<BaseResponse>({
    url: `dsMember/${memberId}/password/reset`,
    data,
  })
}
// 编辑用户
export function EditUserList(data: object) {
  return request.post<BaseResponse>({
    url: `dsMember`,
    data,
  })
}
// 错题收藏
export function getSpecialQuestion(data: object) {
  return request.post<BaseResponse>({
    url: `pcExam/getPartQuestion`,
    data,
  })
}
// 根据车型获取答题数据
export function getProgressToCarMode(data: object) {
  return request.post<BaseResponse>({
    url: `pcExam/getProgressToCarMode`,
    data,
  })
}
// 根据车型-考试id获取考试题目
export function getSimulateQuestion(data: object) {
  return request.post<BaseResponse>({
    url: `pcExam/getExamQuestion`,
    data,
  })
}

// 获取diy页面
export function getDiyPage(data: object) {
  return request.post<BaseResponse>({
    url: 'pc/diyMenu/getDiyPage',
    data,
  })
}
// 根据考试id更新考试状态/时间
export function updateExamStatus(data: object) {
  return request.post<BaseResponse>({
    url: `pcExam/updateExamStatus`,
    data,
  })
}
// 分页查询题目分组
export function getQuestionInfo(data: object) {
  return request.get<BaseResponse>({
    url: `pcExam/pageV2`,
    params: data,
  })
}
// 获取全量考试基础信息
export function getExamAll(data: object) {
  return request.post<BaseResponse>({
    url: `pcExam/getExamAll`,
    data
  })
}
// 获取考试配置信息
export function getExamConfig(data: object) {
  return request.get<BaseResponse>({
    url: `pcExam/getExamConfig`,
    params: data
  })
}
// 清楚记录
export function clearBytype(data: object) {
  return request.get<BaseResponse>({
    url: `pcExam/clearBytype`,
    params: data
  })
}
// 获取考试配置信息
export function statDataToType(data: object) {
  return request.get<BaseResponse>({
    url: `pcExam/statDataToType`,
    params: data
  })
}
// 获取考试配置信息
export function getDailyStatistics(data: object) {
  return request.post<BaseResponse>({
    url: `pcExam/getDailyStatistics`,
    data
  })
}
// 语音合成
export function getSpeechSynthesis(data: object) {
  return request.post<BaseResponse>({
    url: `pcExam/textToVoice`,
    data
  })
}
// 查询当前驾校车型相关数据
export function getCarList() {
  return request.post<BaseResponse>({
    url: `pcExam/getCarMode`
  })
}
// 查询当前驾校车型相关数据
export function editUserInfo(data: object) {
  return request.post<BaseResponse>({
    url: `pcExam/updateUserInfo`,
    data
  })
}
